package com.cy.sc.controller;

import com.cy.sc.pojo.Staff;
import com.cy.sc.service.StaffClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <br>@class: StaffConsumerController
 * <br>@description: 服务消费者Feign版
 * <br>@author: cy
 * <br>@date: 2020-04-01 15:17:58
 * <br>@version: 1.0
 * <br>
 * <br>@since: (版本) 作者 时间 注释
 */
@RestController
@RequestMapping("/consumer/staff")
public class StaffConsumerController {
    //Feign模式更像 service ，感觉不到在调用远程
    @Autowired
    private StaffClientService staffClientService;

    @RequestMapping("/get/{id}")
    public Staff get(@PathVariable("id") long id) {
        return this.staffClientService.queryById(id);
    }

    @RequestMapping("/list")
    public List<Staff> list() {
        return this.staffClientService.queryAll();
    }

    @RequestMapping("/add")
    public boolean add(Staff staff) {
        return this.staffClientService.addStaff(staff);
    }

}
